home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Celestin Apprentice 4
/
Apprentice-Release4.iso
/
Source Code
/
C
/
Frameworks
/
Grant's CGI Framework 1.0b12
/
MyHandlers.c
< prev
next >
Wrap
Text File
|
1995-12-09
|
4KB
|
193 lines
/*****
*
* MyHandlers.c
*
* Optional custom functions to handle special events. Includes:
* document opening, startup and quitting
*
* Modify these functions if you need to add to the standard support
* built into the framework.
*
* The function prototypes are contained in the relevent headers.
* For example, AEHandlers.h contains the prototype for MyOpenDocument
*
* This is a support file for "Grant's CGI Framework".
* Please see the license agreement that accompanies the distribution package
* for licensing details.
*
* Copyright ©1995 by Grant Neufeld
* grant@acm.com
* http://arpp1.carleton.ca/grant/
*
*****/
#include "MyConfiguration.h"
#include "compiler_stuff.h"
#if kCompileWithDragNDrop
#include <Drag.h>
#endif
#include "AEHandlers.h"
#include "CGI.h"
#include "DebugUtil.h"
#include "EventUtil.h"
#include "ListSTAR.h"
#include "Quit.h"
#include "Startup.h"
#include "WindowInt.h"
/*** FUNCTIONS ***/
#pragma segment AppleEvents
/* The application is expected to open the given documents, if possible */
OSErr
MyOpenDocument ( FSSpec *theFile )
{
OSErr theErr;
my_assert ( theFile != nil, "\p: theFile ptr is nil" );
theErr = noErr;
return theErr;
} /* MyOpenDocument */
#pragma segment Utilities
/* Close any custom application windows */
#if kCompileWithApplicationWindows
OSErr
MyCloseWindow ( WindowPtr theWindow )
{
OSErr theErr;
theErr = noErr;
return theErr;
} /* MyCloseWindow */
#endif
/* If activate is true, restore theWindow's selections.
If activate is false, hide, or reduce to outline, theWindow's selections.
If theWindow has a grow box in the bottom right corner,
you should invalidate the growrect */
#if kCompileWithApplicationWindows
void
MyActivateWindow ( WindowPtr theWindow, Boolean activate )
{
} /* MyUpdateWindow */
#endif
/* Draw contents of window on an update event */
#if kCompileWithApplicationWindows
void
MyUpdateWindow ( WindowPtr theWindow )
{
} /* MyUpdateWindow */
#endif
/* Support a click in a window.
If the click is on a dragable item, set onDragItem to true. */
#if kCompileWithApplicationWindows
void
MyClickInWindow ( WindowPtr theWindow, Point thePoint, Boolean *onDragItem )
{
} /* MyClickInWindow */
#endif
/* If you add windows that allow for text entry or you accept non-command-key
keyboard input, you need to support this function. */
#if kCompileWithKeyboardEvents
void
MyKeyPress ( EventRecord *theEvent )
{
} /* MyKeyPress */
#endif
/* */
#if kCompileWithDragNDrop
OSErr
MyDoStartDrag ( EventRecord *theEvent, WindowPtr theWindow )
{
OSErr theErr;
GrafPtr savePort;
DragReference theDrag;
RgnHandle dragRegion;
GetPort ( &savePort );
SetPort ( (GrafPtr)theWindow );
theErr = NewDrag ( &theDrag );
if ( theErr == noErr )
{
dragRegion = NewRgn ();
/* ••• You need to call a function that sets up the drag values such as:
theErr = customSetupDrag ( theWindow, theDrag, dragRegion, theEvent->where ); */
}
else
{
theDrag = nil;
}
SetPort ( savePort );
theErr = TrackDrag ( theDrag, theEvent, dragRegion );
if ( dragRegion != nil )
{
DisposeRgn ( dragRegion );
}
if ( theDrag != nil )
{
DisposeDrag ( theDrag );
}
return theErr;
} /* MyDoStartDrag */
#endif
#pragma segment Startup
/* add things like installing additional AppleEvent handlers in this function */
OSErr
MyStartup ( void )
{
OSErr theErr;
MyCGIStartup (); /* CGI Specific */
MyListSTARStartup (); /* ListSTAR Specific */
theErr = noErr;
return theErr;
} /* MyStartup */
#pragma segment Main
/* Unless allowUserInteract is true, don't make any calls that might require
user interaction.
Return true if your clean up was successful and quitting should proceed. */
Boolean
MyQuit ( Boolean allowUserInteract )
{
return MyCGIQuit ( allowUserInteract );
} /* MyQuit */
/***** EOF *****/